package com.succez.server.servlet.http;

import java.util.HashMap;
import java.util.Map;

import com.succez.server.servlet.ServletContext;

/**
 * 一个web应用对应的配置
 */
public class WebApp {
    /**
     * 应用启动的时候进行初始化，之后不会更改
     */
    public static ServletContext servletContext;

    /**
     * ContentType类型
     */
    public static Map<String, String> contentTypeMappings;
    
    /**
     * 状态码和状态类型描述
     */
    public static Map<Integer, String> statusCodeMappings;

    static {
        // 设置默认的ContentType
        contentTypeMappings = new HashMap<>();
        contentTypeMappings.put("html", "text/html;charset=utf-8");
        contentTypeMappings.put("txt", "text/plain;charset=utf-8");
        contentTypeMappings.put("js", "application/javascript;charset=utf-8");
        contentTypeMappings.put("css", "text/css;charset=utf-8");
        contentTypeMappings.put("xml", "text/xml");
        contentTypeMappings.put("gif", "image/gif");
        contentTypeMappings.put("jpg", "image/jpeg");
        contentTypeMappings.put("png", "image/png");
        contentTypeMappings.put("ico", "image/x-icon");
        contentTypeMappings.put("postDefaultEncode", "application/x-www-form-urlencoded");
        contentTypeMappings.put("xhtml", "application/xhtml+xml");
        contentTypeMappings.put("xml", "application/xml");
        contentTypeMappings.put("atomxml", "application/atom+xml");
        contentTypeMappings.put("json", "application/json;charset=utf-8");
        contentTypeMappings.put("pdf", "application/pdf");
        contentTypeMappings.put("word", "application/msword");
        contentTypeMappings.put("download", "application/octet-stream");

        // 设置默认status code描述
        statusCodeMappings = new HashMap<>();
        statusCodeMappings.put(100, "continue");
        statusCodeMappings.put(101, "Switch Protocols");
        statusCodeMappings.put(200, "OK");
        statusCodeMappings.put(201, "Created");
        statusCodeMappings.put(202, "Accepted");
        statusCodeMappings.put(203, "Non-authoritative Information");
        statusCodeMappings.put(204, "No Content");
        statusCodeMappings.put(300, " Multiple Choices");
        statusCodeMappings.put(301, "Moved Permanently");
        statusCodeMappings.put(400, "Bad Request");
        statusCodeMappings.put(401, "Unauthorized");
        statusCodeMappings.put(403, "Forbidden");
        statusCodeMappings.put(404, "Not Found");
        statusCodeMappings.put(500, "Internal Server Error");
    }
}